package com.qk.mapper;

import com.qk.dto.UserDto;
import com.qk.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 动态条件分页查询用户列表
     */
    List<User> getUsers(UserDto userDto);

    /**
     * 新增用户
     * @param user
     */
    @Insert("INSERT INTO user(username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time) " +
            "VALUES(#{username}, #{password}, #{name}, #{phone}, #{email}, #{gender}, #{status}, #{deptId}, #{roleId}, #{image}, #{remark}, #{createTime}, #{updateTime})")
    void insert(User user);




    /**
     * 删除用户
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 根据ID查询用户信息
     */
    @Select("SELECT id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time  FROM user WHERE id = #{id}")
    User selectById(Integer id);

    /**
     * 修改用户信息
     */
    void update(User user);

    /**
     * 根据角色标识查询用户列表
     */
    List<User> getUsersByRoleLabel(String roleLabel);


}
